package com.baizhi.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.ICaptcha;
import com.baizhi.exception.CmfzException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
@RequestMapping("captcha")
public class HuToolCaptchaUtil {

    @RequestMapping("get")
    public void getCaptcha(HttpServletResponse response, HttpSession session) throws IOException {
        ICaptcha captcha= CaptchaUtil.createCircleCaptcha(200, 100, 4, 20);
        session.setAttribute("captcha",captcha);
        captcha.write(response.getOutputStream());
    }
}
